home *** CD-ROM | disk | FTP | other *** search
- Path: ccnet.com!usenet
- From: paulp@ccnet.com (Paul Pedriana)
- Newsgroups: comp.lang.c++
- Subject: Re: Derived class not calling overloaded base class function
- Date: Sat, 24 Feb 1996 19:29:09 GMT
- Organization: Two-Bit Software
- Message-ID: <4gnp1m$q0m@ccnet2.ccnet.com>
- References: <4g46t2$3vd@otis.netspace.net.au>
- NNTP-Posting-Host: h96-194.ccnet.com
-
- >I have a class, say 'foo' (everyone's favourite) which has a member function
- >'int Get(void)'
-
- >I then derive a class (say 'goo') which has as a base class foo. If goo has a
- >function also called Get, but with different params (say ''char *Get(char *)') I can't
- >seem to get the base class' Get() function to operate within the derived class.
-
- >If I say just plain "Get()" it says too few parameters (for Get(char *)". If I use
- >"::Get()" the compiler complains Get should have a prototype. If I say "foo.Get()" it
- >says improper use of typedef foo. The only way seems to be to explicitly cast the
- >this pointer to a foo.
-
- >Surely there is a better way than this? Thanks for any help (e-mail preferred)
-
- The effect you are seeing is called function hiding. If a subclass defines a
- function with the same name as any parent function, all parent functions with
- the same name are hidden and must be redeclared in the subclass. I forget the
- exact reason for this or the exact details of the implementation, so the experts
- can respond with more details. Your compiler should have generated warnings when
- compiling the subclass that it was hiding Get() from the parent class.
-
- Paul Pedriana
- paulp@ccnet.com
-
-